home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94a.txt
/
000039_icon-group-sender _Fri Jan 28 22:30:28 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-08-19
|
2KB
Received: by cheltenham.cs.arizona.edu; Sun, 6 Feb 1994 20:13:59 MST
Date: 28 Jan 94 22:30:28 GMT
From: cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!newncar!csn!server!usenet@ucbvax.Berkeley.EDU (Cheyenne Wills)
Organization: Storage Technology Corp.
Subject: Re: Table look up questions?
Message-Id: <CKD2Iu.HI9@stortek.com>
References: <2ibt39$ojg@uop.cs.uop.edu>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
In <2ibt39$ojg@uop.cs.uop.edu>, wclark@uop.edu (William Clark) writes:
........
>
> Example: User inputs: H W <enter>
> Output: Hello World
>
> Where "H W" is a key in the table and "Hello World" is the other
> half.
.......
>
> William R. Clark
> University of the Pacific
> wclark@thor.cs.uop.edu
>
Icon has builting table support, basically dynamic arrays that
are "indexed" by a string (associtive arrays). So for your example:
procedure main()
wordtbl := table()
wordtbl["H W"] := "Hello World"
wordtbl["G D"] := "Good Day"
wordtbl["G B"] := "Good By"
write("User input:")
line := read()
line := trim(line)
newline := wordtbl[line]
write("Output: ",newline)
end
Of course things like making checking to see if the data was in
the table can be done by simply testing to see if "wordtbl[line]"
is &null. Also the issue of upper/lower case and multiple blanks
hasn't been addressed.
+--------------------------------------+---------------------------------+
| +-----+ | Cheyenne Wills |
| | | "From here on up it is | Storage Technology Corporation |
| | +--+--+ downhill all the way" | 2270 South 88th St. |
| | | | | | Louisville, Co. 80028-4232 |
| +--+--+ | These are not the | |
| | | opinions or views of | Cheyenne_Wills@stortek.com |
| +-----+ Storage Technology | cheyenne@witsend.stortek.com |
+--------------------------------------+---------------------------------+